﻿using System;
using System.Data;
using System.Configuration;

using System.Collections;
using System.Web;
using System.Web.Security;

using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Component;


public partial class BackEnd_CategoryModify : System.Web.UI.UserControl
{
    public string _DigitalError = ""; bool _CSSX = true;

    protected void Page_Load(object sender, EventArgs e)
    {
        this.rfvtxtEL.ErrorMessage = ConstString._NhapNoiDung; ;
        this.rfvtxtVN.ErrorMessage = ConstString._NhapNoiDung; ;
        if (QueryHelper.GetQueryString(Request, ConstString._CSSX) == ConstString._ML)
            _CSSX = false;
        else
            _CSSX = true;
    }
   
    public void cmdLuu_Click(object sender, System.EventArgs e)
    {
        Category cat = new Category(KetNoiCSDL.session);
        cat.Name = this.txtVN.Text.Trim();
        cat.NameEL = this.txtEL.Text.Trim();
        cat.Priority =ConvertType.ToInt(this.txtPriority.Text.Trim());
        cat.CoSoSX = _CSSX;
        if (Config.CheckDigitNumber(this.txtPriority.Text) == false)
        {
            this.txtPriority.Focus();
            _DigitalError = Languages.SearchByKeyWord("ktso");
            return;
        }
        cat.Active = ConvertType.ToBool(this.ddlActive.Text.Trim());
        if (CategoryDB.Save(cat) == 1) 
        {
            cat.UrlAdmin = BackEndQuery._AdminQuery + BackEndQuery._CategorySubL + "&" + Component.ConstString._idcat + "="+cat.Id.ToString();
            cat.UrlFronent = "GetListProductByCat("+cat.Id+")";
            CategoryDB.Save(cat);
            this.lbMessage.Text = "Thành công";
        }
        // Response.Redirect(Request.Url.ToString());
    }
}
